<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>JQparent</title>
    <script src = 'jquery-1.12.4.min.js'></script>
    <style>
        *{
            margin: 0;
            padding: 0;
        }
        .bord{
            border: 1px dashed #ee2602;
            width: 90%;
            margin: 20px auto;
        }
        .title{
            font-size: 20px;
            font-weight: bold;
            margin: 20px;
        }
        .introduce{
            font-size: 16px;
            margin: 0 0 20px 50px;
        }
        .red{
            color: red;
        }
    </style>
    <script>
        jQuery(function ($) {
            $('.mybtn').click(function () {
                $('form > input').css({backgroundColor:'red'})
            })
        });
    </script>
</head>
<body>
<div class="bord">
    <div class="title">JQparent</div>
    <div class="introduce">在给定的父元素下匹配所有的子元素</div>
</div>
<div class="bord">
    <div class="title">演示效果</div>
    <div class="introduce">
        <form>
            <label>Name:</label>
            <input name="name" />
            <fieldset>
                <label>Newsletter:</label>
                <input name="newsletter" />
            </fieldset>
        </form>
        <input name="none" />
        <br/>
        <br/>
        <button class="mybtn">查找form > input的元素,变背景色为红色。</button>
    </div>
</div>
</div>
<div class="bord">
    <div class="title">代码</div>
    <div class="introduce">
            <pre>
&lt;script&gt;
    jQuery(function ($) {
        $('.mybtn').click(function () {
                $('<a class="red"> form > input</a>').css({backgroundColor:'red'})
        })
    });
&lt;/script&gt;
&lt;html&gt;
    &lt;div class="introduce"&gt;
        &lt;form&gt;
            &lt;label&gt;Name:&lt;/label&gt;
            &lt;input name="name"/&gt;
            &lt;fieldset&gt;
                &lt;label&gt;Newsletter:&lt;/label&gt;
                &lt;input name="newsletter"/&gt;
            &lt;/fieldset&gt;
        &lt;/form&gt;
        &lt;input name="none"/&gt;
        &lt;br/&gt;
        &lt;br/&gt;
        &lt;button class="mybtn"&gt;查找form &gt; input的元素,变背景色为红色。&lt;/button&gt;
    &lt;/div&gt;
&lt;/html&gt;
            </pre>
    </div>
</div>
</body>
</html>